package com.yoke;

import org.dom4j.DocumentException;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by jiangzeyin on 2017/6/7.
 */
public class Target {
    static String path = "D:/Ide/yzb/";
    private static List<File> list = new ArrayList();

    public static void main(String[] args) throws Exception {
        scannerFile(path);
        for (File file : list) {
            System.out.println("清理：" + file.getPath());
            main.deleteDir(file);
        }
        System.out.println("处理结束");
    }

    public static void scannerFile(String path) throws DocumentException, IOException, InterruptedException {
        File file = new File(path);
        if (!file.exists()) {
            System.out.println("没有找到文件");
            return;
        }
        File[] files = file.listFiles();
        if (files == null)
            return;
        for (File item : files) {
            String itemPath = item.getPath();
            String itemName = item.getName();
            if (itemName.startsWith(".") || "src".equals(itemName) || itemName.endsWith(".iml"))
                continue;
            if ("pom.xml".equals(itemName)) {
                File targetFile = new File(new File(itemPath).getParentFile(), "target/classes");
                list.add(targetFile.getParentFile());
            } else {
                scannerFile(itemPath);
            }
        }
    }
}
